package com.mdl.api.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.mdl.api.dto.CommonResult;
import com.mdl.api.entity.TpzQysbYw;
import com.mdl.mall.util.FileDownloadUtil;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

/**
 * @Desc
 * @Author madengling
 * @Time 2020/9/14 9:14
 */
@Controller
@RequestMapping("/hello")
public class HelloController {

    @RequestMapping("/hello")
    public String index(Model model, HttpServletResponse response) {
        model.addAttribute("singlePerson", "ceshi");
        return "model";
    }

    @RequestMapping("/json")
    @ResponseBody
    public CommonResult jsonTest(TpzQysbYw tpzQysbYw) {
        CommonResult commonResult = new CommonResult();
        System.out.println(tpzQysbYw.getId());
        System.out.println(tpzQysbYw.getAccept_code());
        System.out.println(tpzQysbYw.getSbzt());
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("retcode",200);
        jsonObject.put("msg","资料保存成功！");
        Long time = System.currentTimeMillis();
        JSONArray array = new JSONArray();
        array.add(jsonObject);
        jsonObject.put("time",time);
        array.add(jsonObject);

        List<TpzQysbYw> fwxxVoList = new ArrayList<>();
        fwxxVoList.add(tpzQysbYw);
        fwxxVoList.add(tpzQysbYw);

        JSONObject jsonObject1 = new JSONObject();
        jsonObject1.put("ysxmbh", "ysxmcode");
        jsonObject1.put("fwxxlist", fwxxVoList);//JSONArray.parseArray(JSON.toJSONString(
        commonResult.setRetcode("152");
        commonResult.setRetdata(jsonObject1);
        commonResult.setRetmsg("ceshio");
        return commonResult;
    }





}
